package com.bupt.ilink.controller;

import com.bupt.ilink.entity.folder.Folder;
import com.bupt.ilink.request.Application.CreateFolderRequest;
import com.bupt.ilink.request.Application.PersonalFlowQueryByFolderConditionRequest;
import com.bupt.ilink.service.PersonalFlowService;
import com.bupt.ilink.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("personal_app")
public class PersonalFlowController {

    @Autowired
    PersonalFlowService personalFlowService;

    @GetMapping("/folders")
    public R getAppsInFolder(@ModelAttribute PersonalFlowQueryByFolderConditionRequest params){
        return R.ok(personalFlowService.getAppsInFolder(params));
    }

    @PostMapping("/folders")
    public R createFolder(@RequestBody CreateFolderRequest createFolderRequest){
        return R.ok(personalFlowService.createFolder(createFolderRequest));
    }

    @PatchMapping("/folders/{folder_id}")
    public R changeFolderInfo(@PathVariable("folder_id") String folderId,@RequestBody CreateFolderRequest createFolderRequest){
        return R.ok(personalFlowService.changeFolderInfo(folderId,createFolderRequest));
    }

    @DeleteMapping("/folders/{folder_id}")
    public R deleteFolder(@PathVariable("folder_id") String folderId){
        return R.ok(personalFlowService.deleteFolder(folderId));
    }

    @DeleteMapping("/delete_flows")
    public R deleteFlows(@RequestBody List<String> flowIds){
        return R.ok(null,personalFlowService.deleteFlows(flowIds));
    }

}
